package com.oss.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.users.User;

/**
 * @author xueqiang.mi
 * @date 2010-2-2
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Tag implements Serializable {
	private static final long serialVersionUID = 4563415935824903474L;
	@PrimaryKey
	private String id;

	@Persistent
	private String name;

	@Persistent
	private String description;

	@Persistent
	private User createdAuthor;

	@Persistent
	private Date createdDate;

	@Persistent
	private Boolean enabled = true;

	@Persistent
	private Boolean frozen = false;

	@Persistent
	private String parent;

	@NotPersistent
	private List<Tag> children = null;

	public List<Tag> getChildren() {
		return children;
	}

	public void setChildren(List<Tag> children) {
		this.children = children;
	}

	public Tag() {
		super();
	}

	public User getCreatedAuthor() {
		return createdAuthor;
	}

	public Date getCreatedDate() {
		return createdDate;
	}

	public String getDescription() {
		return description;
	}

	public Boolean getEnabled() {
		return enabled;
	}

	public Boolean getFrozen() {
		return frozen;
	}

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getParent() {
		return parent;
	}

	public boolean isNew() {
		return (this.id == null);
	}

	public void setCreatedAuthor(User createdAuthor) {
		this.createdAuthor = createdAuthor;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}

	public void setFrozen(Boolean frozen) {
		this.frozen = frozen;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setParent(String parent) {
		this.parent = parent;
	}

	@Override
	public String toString() {
		return "Tag [id=" + id + ", name=" + name + "]";
	}

}
